#include "samptestconfig.h"
#include "ui_samptestconfig.h"

SampTestConfig::SampTestConfig(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::SampTestConfig)
{
    ui->setupUi(this);
    setDialogShadow(this, ui->wgtAdaptive);
    setFixedSize(680,380);

    initContent();
}

SampTestConfig::~SampTestConfig()
{
    delete ui;
}

void SampTestConfig::on_btnReturn_clicked()
{
    saveConfigInfo();
    close();
}

void SampTestConfig::initContent()
{
    QStringList templist1;
    templist1<<tr("250uL");
    ui->cbx_PlungerpumpTypeAdptive->addItems(templist1);        //吸样容器类型
    ui->cbx_DrainplungerpumpTypeAdptive->addItems(templist1);   //排样柱塞泵类型

    QStringList templist3;
    templist3<<tr("固定位置吸样");
    ui->cbx_SamplingmethodAdptive->addItems(templist3);
    ui->cbx_LayoutmethodAdptive->addItems(templist3);

    ui->ldt_AirAdptive->setText("200");
    ui->ldt_AirAdptive->setPlaceholderText("0 ~ 2500");

    ui->ldt_SpeedAdptive->setText("0");
    ui->ldt_SpeedAdptive->setPlaceholderText("0 ~ 4294967295");

    ui->ldt_AirColumnAdptive->setText("200");
    ui->ldt_AirColumnAdptive->setPlaceholderText("0 ~ 2500");

    ui->ldt_WaitingtimeAdptive->setText("0");
    ui->ldt_WaitingtimeAdptive->setPlaceholderText("0 ~ 600");

    ui->ldt_RateDischargeAdptive->setText("0");
    ui->ldt_RateDischargeAdptive->setPlaceholderText("0 ~ 4294967295");

    ui->ldt_ArrangetransferaircolumnAdptive->setText("200");
    ui->ldt_ArrangetransferaircolumnAdptive->setPlaceholderText("0 ~ 2500");

    ui->ldt_ArrangeWaitingtimeAdptive->setText("0");
    ui->ldt_ArrangeWaitingtimeAdptive->setPlaceholderText("0 ~ 600");

    ui->ldt_DischargeVolumeAirColumnAdptive->setText("0");
    ui->ldt_DischargeVolumeAirColumnAdptive->setPlaceholderText("0 ~ 2500");
}

void SampTestConfig::saveConfigInfo()
{
    m_mapSampCfg.clear();

    int nSampPumpID = 0;//柱塞泵类型
    nSampPumpID = ui->cbx_PlungerpumpTypeAdptive->currentIndex()+1;
    m_mapSampCfg.insert("nSampPumpID",nSampPumpID);

    int nSampAirID = 0;//前隔离空气柱
    nSampAirID = ui->ldt_AirAdptive->text().toInt();
    m_mapSampCfg.insert("nSampAirID",nSampAirID);

    int nSampSpeedID = 0;//吸样速度
    nSampSpeedID = ui->ldt_SpeedAdptive->text().toInt();
    m_mapSampCfg.insert("nSampSpeedID",nSampSpeedID);

    int nSampmethodID = 0;//吸样方式
    nSampmethodID = ui->cbx_SamplingmethodAdptive->currentIndex();
    m_mapSampCfg.insert("nSampmethodID",nSampmethodID);

    int nAirColumnID = 0;//转移空气柱
    nAirColumnID = ui->ldt_AirColumnAdptive->text().toInt();
    m_mapSampCfg.insert("nAirColumnID",nAirColumnID);

    int nWaitingtimeID = 0;//吸样后等待时间
    nWaitingtimeID = ui->ldt_WaitingtimeAdptive->text().toInt();
    m_mapSampCfg.insert("nWaitingtimeID",nWaitingtimeID);

    int nDrainPumpTypeID = 0;//排样柱塞泵类型
    nDrainPumpTypeID = ui->cbx_DrainplungerpumpTypeAdptive->currentIndex()+1;
    m_mapSampCfg.insert("nDrainPumpTypeID",nDrainPumpTypeID);

    int nRateDischargeID = 0;//排样速度
    nRateDischargeID = ui->ldt_RateDischargeAdptive->text().toInt();
    m_mapSampCfg.insert("nRateDischargeID",nRateDischargeID);

    int nDrainMethodID = 0;//排样方式
    nDrainMethodID = ui->cbx_LayoutmethodAdptive->currentIndex();
    m_mapSampCfg.insert("nDrainMethodID",nDrainMethodID);

    int nDrainAirColumnID = 0;//排转移空气柱
    nDrainAirColumnID = ui->ldt_ArrangetransferaircolumnAdptive->text().toInt();
    m_mapSampCfg.insert("nDrainAirColumnID",nDrainAirColumnID);

    int nDrainWaitingtimeID = 0;//排样后等待时间
    nDrainWaitingtimeID = ui->ldt_ArrangeWaitingtimeAdptive->text().toInt();
    m_mapSampCfg.insert("nDrainWaitingtimeID",nDrainWaitingtimeID);

    int nVolumeAirColumnID = 0;//排前隔离空气柱量
    nVolumeAirColumnID = ui->ldt_DischargeVolumeAirColumnAdptive->text().toInt();
    m_mapSampCfg.insert("nVolumeAirColumnID",nVolumeAirColumnID);
}

void SampTestConfig::getConfigInfo(QMap<QString,int> &mapCfg)
{
    mapCfg = m_mapSampCfg;
}

